<template>
  <div class="wrap" v-if="hotwords.length">
    <h2 class="title">大家都在搜</h2>
    <div class="list">
      <van-tag
        class="tag"
        v-for="item in hotwords"
        :key="item.id"
        @click="onClick(item)"
      >
        {{ item.keyword }}
      </van-tag>
    </div>
  </div>
</template>

<script>
import { Tag as VanTag } from 'vant'
export default {
  name: 'SearchHotword',
  components: {
    VanTag
  },
  props: {
    hotwords: {
      type: Array
    }
  },
  methods: {
    onClick (item) {
      this.$emit('tag-click', item.keyword)
    }
  }
}
</script>

<style lang="scss" scoped>
  .wrap{
    display: flex;
    flex-direction: column;
    padding: {
      left: rem(10px);
      right: rem(10px);
      top: rem(10px);
    };
    margin-bottom: rem(25px);
    .title{
      font-size: rem(14px);
      font-weight: 500;
      margin: 0;
      color: $color-text-secondary;
    }
    .tag{
      height: rem(34px);
      line-height: rem(33px);
      margin-top: rem(12px);
      margin-right: rem(10px);
      background-color: $color-white;
      border: 1px solid #ccc;
      padding: rem(5px) rem(10px);
      border-radius: rem(17px);
      color: $color-text-regular;
      box-sizing: border-box;
      font-size: rem(13px);
    }
  }
</style>
